<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			#header{
				height: 80px;
				background-color: red;
			}
			#search{
				height: 40px;
				margin-top: 4px;
				border: 3px red solid; 
			}
			body{
				height: 10000px;
			}
			.f{
				position: fixed;
				top: 10px;
				width: 500px;
			}
		</style>
		<script>
			window.onscroll=function(){
				var w=document.documentElement.scrollTop||document.body.scrollTop;
				console.log(w);
				console.log(document.getElementById("search").offsetTop);
				if(w>=window.innerHeight/2){
					document.getElementById("search").classList.add("f");
				}else{
					document.getElementById("search").classList.remove("f");
				}
			}
		</script>
	</head>
	<body>
		<div id="header"></div>
		<div id="search">
			<input type="text"/>
		</div>
	</body>
</html>